package com.linkoog.devtools.toolwindow_manager;

import org.jetbrains.annotations.NotNull;

/**
 *
 */
class ToolWindowPreference implements Comparable<ToolWindowPreference> {
    private final String id;
    private final AvailabilityPreference availabilityPreference;

    ToolWindowPreference(@NotNull final String id, @NotNull AvailabilityPreference availabilityPreference) {
        this.id = id;
        this.availabilityPreference = availabilityPreference;
    }

    @NotNull
    public String getId() {
        return id;
    }

    @NotNull AvailabilityPreference getAvailabilityPreference() {
        return availabilityPreference;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }

        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }

        ToolWindowPreference that = (ToolWindowPreference) obj;

        if (availabilityPreference != that.availabilityPreference) {
            return false;
        }

        return id.equals(that.id);
    }

    @Override
    public int hashCode() {
        int result = id.hashCode();
        result = 31 * result + availabilityPreference.hashCode();

        return result;
    }

    public int compareTo(ToolWindowPreference o) {
        if (o == null) {
            throw new NullPointerException("Cannot compare to null");
        }

        return id.compareTo(o.id);
    }
}
